# {{ ansible_managed }}

[DEFAULT]

ignoreip = {{ fail2ban_ignoreip }}
bantime  = {{ fail2ban_bantime }}
maxretry = {{ fail2ban_maxretry }}

backend = {{fail2ban_backend}}

destemail = {{ fail2ban_destemail }}
banaction = {{ fail2ban_banaction }}
mta = {{ fail2ban_mta }}
protocol = {{ fail2ban_protocol }}
chain = {{ fail2ban_chain }}

action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]

action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
              %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"]

action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
               %(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"]

action = %({{ fail2ban_action }})s

{% if fail2ban_services is iterable %}
{% for service in fail2ban_services %}
[{{ service.name }}]

enabled = {{ service.enabled | default("true") }}
port = {{ service.port }}
filter = {{ service.filter }}
logpath = {{ service.logpath }}
{% if service.maxretry is defined %}
maxretry = {{ service.maxretry }}
{% endif %}
{% if service.protocol is defined %}
protocol = {{ service.protocol }}
{% endif %}
{% if service.action is defined %}
action = %({{ service.action }})s
{% endif %}
{% if service.banaction is defined %}
banaction = {{ service.banaction }}
{% endif %}

{% endfor %}
{% endif %}
